from common import *

import pylab

def DivideMatrixInXRowBlocksFunc(in0,*out):
    while True:
        problem = in0()

        real_h = len(problem)
        real_w = len(problem[0])
        
        # Clear borders!
        #for x in range(real_w):
        #    problem[0][x] = 0
        #    problem[-1][x] = 0
        #for y in range(real_h):
        #    problem[y][0] = 0
        #    problem[y][-1] = 0
    

        pc = len(out)

        for p in range(pc):

            # localize my problem
            size = round(len(problem)/pc)

            if (p == 0):
                line1 = problem[0]
            else:
                line1 = problem[(p*size)-1]
                
            if ((p+1) == pc):
                line2 = problem[-1]
            else:
                line2 = problem[((p+1)*size)]

            block = pylab.concatenate(([line1],problem[p*size:((p+1)*size)],[line2]))
            out[p](block)

